//
//  TabBarVc.m
//  new
//
//  Created by going on 16/3/15.
//  Copyright © 2016年 going_Shui. All rights reserved.
//

#import "TabBarVc.h"
#import "MainViewController.h"
#import "VipHelpViewController.h"
#import "PlatformRuleViewController.h"
#import "MyCenterViewController.h"





@interface TabBarVc ()<UITabBarControllerDelegate,UIAlertViewDelegate>

{
//    TabBarVc * _tabBarVc;
}
@end

@implementation TabBarVc

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    

    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
//   [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];
//    [UITabBar appearance].translucent = NO;

//    [self configTabBar];
    [self creatViewControllers];
    

}

//-(void)configTabBar {
//    self.tabBar.translucent = NO;
//}

-(void)creatViewControllers {
    
    MainViewController * homeVC = [[MainViewController alloc]init];
    [self addChildViewController:homeVC title:@"首页"imageName:@"icon_tab_home_pre" selectedImageName:@"icon_tab_home"];

    VipHelpViewController * shoper = [[VipHelpViewController alloc]init];
    [self addChildViewController:shoper title:@"互助帮扶" imageName:@"icon_tab_cooperation_pre" selectedImageName:@"icon_tab_cooperation"];

    PlatformRuleViewController * rule = [[PlatformRuleViewController alloc]init];
    [self addChildViewController:rule title:@"平台规则" imageName:@"icon_tab_rule_pre" selectedImageName:@"icon_tab_rule"];
    
    MyCenterViewController   * myCenterVC = [[MyCenterViewController alloc]init];
    [self addChildViewController:myCenterVC title:@"个人中心" imageName:@"icon_tab_user_pre" selectedImageName:@"icon_tab_user"];
}
/**
 *  封装添加vc的方法
 */
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    childController.title = title;
    childController.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childController];
//     [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"img_home_nav_bg"] forBarMetrics:UIBarMetricsDefault];
     nav.navigationBar.barTintColor = NavBackColor;
    nav.navigationBar.translucent = NO;
    [self addChildViewController:nav];
    
    NSDictionary * detdic =@{NSForegroundColorAttributeName:[UIColor lightGrayColor]};
    [nav.tabBarItem setTitleTextAttributes:detdic forState:UIControlStateNormal];
    //改变颜色
    NSDictionary * seledic =@{NSForegroundColorAttributeName:NavBackColor};
    [nav.tabBarItem setTitleTextAttributes:seledic forState:UIControlStateSelected];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
